package com.hqyj.dao;

import com.hqyj.pojo.TbParkingUse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 车位使用表 Mapper 接口
 * </p>
 *
 * @author gp
 * @since 2021-09-26
 */
@Repository
public interface TbParkingUseMapper extends BaseMapper<TbParkingUse> {

    @Select("select * from tb_parking_use where telephone=#{telephone} and owner_name=#{ownerName} ")
    TbParkingUse selectByTelAndOwnerName(@Param("telephone") String telephone , @Param("ownerName") String ownerName);

    @Update("update tb_parking_use set car_number=#{carNumber} , start_time=#{startTime} where id=#{id}")
    int updateMessage(@Param("carNumber") String carNumber , @Param("id")Integer id, @Param("startTime") LocalDateTime startTime);

    @Update("update tb_parking_use set end_time=#{endTime} where id=#{id}")
    int updateEndTime(@Param("id")Integer id, @Param("endTime") LocalDateTime endTime);


    @Update("update tb_parking_use set end_time=#{endTime} where car_number=#{carNumber}")
    int updateEndTimeByCarName(@Param("carNumber")String carNumber, @Param("endTime") LocalDateTime endTime);


    @Select("select * from tb_parking_use where car_number=#{carNumber} ")
    List<TbParkingUse> selectByCarNumber(@Param("carNumber")String carNumber);

    @Update("update tb_parking_use set end_time=#{endTime} where id=#{id}")
    int updateEndTimeById(@Param("id")Integer id, @Param("endTime") LocalDateTime endTime);

    @Update("update tb_parking_use set end_time=#{endTime},total_fee=#{totalFee} where id=#{id}")
    int updateEndTimeAndTotalFeeById(@Param("id")Integer id, @Param("endTime") LocalDateTime endTime,@Param("totalFee")Integer totalFee);

}
